<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>OA办公管理系统</title>
		<link rel="stylesheet" href="css/login.css">
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/global.js"></script>
		<script src="lib/layui/layui.js" charset="utf-8"></script>
	</head>
<div></div>
	<body class="login-bg">
		<canvas id="fullstarbg">你的浏览器不支持canvas标签</canvas>
		<div class="login">
			<div class="message">OA办公管理系统登录</div>

			<div id="darkbannerwrap"></div>
			<form method="post" class="layui-form" onsubmit="return false;" id="fmLogin">
				<input name="loginName" placeholder="用户名" type="text" lay-verify="required" class="layui-input">
				<hr class="hr15">
				<input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
				<hr class="hr15">
				<input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
				<hr class="hr20">
			</form>
		</div>
		<script>
			layui.use('form', function() {
				var form = layui.form;
				var layer = layui.layer;
				var $ = layui.jquery; //引入jquery
				//解决跨域
				$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
					options.xhrFields = {
						withCredentials: true
					}
				})
				//监听提交
				form.on('submit(login)', function(data) {
					$.post(globalData.server + "public/login", $("#fmLogin").serialize(), function(res) {
						if(res.success == true) {
							console.log(res);
							//保存相关数据到本地数据库
							globalData.setUserInfo(res.user.loginName, res.token, res.user.id);
							//转向页面
							window.location.href = "index.html";
						} else {
							console.log(res.message);
							layer.msg(res.message, {
								icon: 2,
								time: 4000
							});
						}
					}, "json");
					return false;
				});
			});
		</script>

		<!-- 底部结束 -->

	</body>

</html>